/*eslint-disable*/
import React, { useState, useEffect } from 'react'
import { Table, Space, Button, Cascader } from 'antd';
import request from '../../../utils/request'

const order = () => {


    const [list, datalist] = useState([])

    useEffect(()=>{
        tablelist()
    },[])

    const tablelist= async ()=>{
        const res=await request.get('/api/list5')
        datalist([...res.data.data])
    }

     //删除
     const Del = (key) => {
        request.delete('/api/list5del', { key: key }).then(res => {
            //重新获取列表
            console.log(res);
            tablelist()
        })
    }
    const options1 = [

        {
            value: '请选择',
            label: '请选择',
        },
        {
            value: '有二手房出租',
            label: '有二手房出租',
        },
        {
            value: '有房出租',
            label: '有房出租',
        },
        {
            value: '我想买个房',
            label: '我想买个房',
        },
        {
            value: '我想租个房',
            label: '我想租个房',
        }
    ];
    function onChange(value) {
        console.log(value);
    }
    //列表结构
    const columns = [
        {
            title: '序号',
            dataIndex: 'key',
            key: 'key',
        },
        {
            title: '编号',
            dataIndex: 'number',
            key: 'number',
        },
        {
            title: '用户名',
            dataIndex: 'name',
            key: 'name',
        },
        {
            title: '手机号',
            dataIndex: 'phone',
            key: 'phone',
        },
        {
            title: '类型',
            dataIndex: 'type',
            key: 'type',
        },
        {
            title: '支付金额',
            dataIndex: 'money',
            key: 'money',
        },
        {
            title: '支付时间',
            dataIndex: 'shijian',
            key: 'shijian',
        },
        {
            title: '操作',
            key: 'action',
            render: (text, record) => (
                <Space size="middle">
                    <a onClick={() => {Del(record.key)}}>删除</a>
                </Space>
            ),
        },
    ];

    return (
        <div>
            <header>
                咨询管理
            </header>
            <div className="div-btn">
                <div>订单管理<span><Cascader options={options1} onChange={onChange} placeholder="请选择" /></span></div>
                <div className="inp">搜索<span><input placeholder="请输入手机号/用户名/订单号" /></span></div>
                <div><Button>查询</Button></div>
            </div>
            <div>
            <Table columns={columns} dataSource={list} />
            </div>
        </div>
    )
}

export default order
